import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { join, resolve } from "path";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import Components from "unplugin-vue-components/vite";
import { VantResolver } from "unplugin-vue-components/resolvers";

export default defineConfig({
    plugins: [
        vue(),
        createSvgIconsPlugin({
            // 指定要缓存的图标文件夹
            iconDirs: [resolve(process.cwd(), "src/icons")],
            // 指定symbolId格式
            symbolId: "icon-[dir]-[name]",
        }),
        Components({
            resolvers: [
                // 自动注册vant组件库
                VantResolver(),
            ],
        }),
    ],
    resolve: {
        // 配置路径别名
        alias: {
            "@": join(__dirname, "src"),
        },
    },
    // 开启IP域名访问
    server: {
        host: true,
        port: 80,
        open: true,
    },
});
